/*     */ package tools;
/*     */ 
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.FileOutputStream;
/*     */ import java.io.PrintStream;
/*     */ import java.text.ParseException;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ import java.util.Properties;
/*     */ import javax.swing.text.MaskFormatter;
/*     */ 
/*     */ public class Tools
/*     */ {
/*  15 */   private static String file_name = "conf/conf.props";
/*     */ 
/*  94 */   public static String mask = "####.####.##";
/*     */ 
/*     */   public static String readprops(String key, String def)
/*     */   {
/*     */     try
/*     */     {
/*  23 */       Properties p = new Properties();
/*  24 */       File fl = new File(file_name);
/*  25 */       System.out.println(fl.getAbsolutePath());
/*  26 */       p.load(new FileInputStream(fl));
/*  27 */       String item = p.getProperty(key);
/*  28 */       if (item.equals("")) {
/*  29 */         return def;
/*     */       }
/*  31 */       return item;
/*     */     }
/*     */     catch (Exception e) {
/*  34 */       System.out.println(e);
/*  35 */     }return def;
/*     */   }
/*     */ 
/*     */   public static void writeprops(String key, String value)
/*     */   {
/*     */     try {
/*  41 */       Properties p = new Properties();
/*  42 */       p.load(new FileInputStream(file_name));
/*     */ 
/*  44 */       p.put(key, value);
/*  45 */       FileOutputStream out = new FileOutputStream(file_name);
/*  46 */       p.store(out, "/* properties updated */");
/*     */     }
/*     */     catch (Exception e) {
/*  49 */       System.out.println(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void saveprops(String file, Properties p) {
/*     */     try {
/*  54 */       FileOutputStream out = new FileOutputStream(file);
/*  55 */       p.store(out, "/* properties updated */");
/*     */     }
/*     */     catch (Exception e) {
/*  58 */       System.out.println(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   public static String convertDate(Date date, String format)
/*     */   {
/*  64 */     SimpleDateFormat sdf = new SimpleDateFormat(format);
/*  65 */     return sdf.format(date);
/*     */   }
/*     */ 
/*     */   public static Date convertLongToDate(String date)
/*     */   {
/*  70 */     String year = date.substring(0, 4);
/*  71 */     String month = date.substring(4, 6);
/*  72 */     String day = date.substring(6, 8);
/*  73 */     String hour = date.substring(8, 10);
/*  74 */     String minute = date.substring(10, 12);
/*  75 */     String second = date.substring(12, 14);
/*     */ 
/*  77 */     Calendar cal = Calendar.getInstance();
/*  78 */     cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), Integer.parseInt(hour), Integer.parseInt(minute), Integer.parseInt(second));
/*     */ 
/*  80 */     return cal.getTime();
/*     */   }
/*     */ 
/*     */   public static Date convertLongToDate1(String date)
/*     */   {
/*  85 */     String year = date.substring(0, 4);
/*  86 */     String month = date.substring(4, 6);
/*  87 */     String day = date.substring(6, 8);
/*     */ 
/*  89 */     Calendar cal = Calendar.getInstance();
/*  90 */     cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day));
/*  91 */     return cal.getTime();
/*     */   }
/*     */ 
/*     */   public static String formatAccount(String string)
/*     */     throws ParseException
/*     */   {
/*  98 */     MaskFormatter mf = new MaskFormatter(mask);
/*     */ 
/* 100 */     mf.setValueContainsLiteralCharacters(false);
/* 101 */     return mf.valueToString(string);
/*     */   }
/*     */ }

/* Location:           F:\BCA.jar
 * Qualified Name:     tools.Tools
 * JD-Core Version:    0.6.0
 */